<template>
  <!-- 导航 -->
  <div class="nav_div">
    <ul class="ul1">
      <li v-for="(item, index) in Lists" :key="index" class="li1" @mouseleave="a()" @mouseover="b(index)" @click="Cate_id(index)">
        {{ item.name }}
        <!-- 经过显示2级导航 -->
        <div :class="{ addclass: index == num }" class="ul2_div">
          <ul class="ul2">
            <li v-for="(item, index) in item.children" :key="index" @click="Cate_next(index)">
              {{ item.name }}
            </li>
          </ul>
        </div>
      </li>
    </ul>
  </div>
</template>
<script>
export default {
  name: 'DetalisNav',
   props: {
    Lists : null,
  },
  data() {
    return {
      num: null
    }
  },
  methods: {
    a() {
      this.num = null
    },
    b(index) {
      this.num = index
    },
    // 点击一级导航获取id
    Cate_id(index){
      // console.log(this.Lists[index].id);
      this.$emit('info',this.Lists[index].id)
    },
    // 点击二级导航获取id
    Cate_next(index){
      // console.log(this.Lists[0].children[index].id)
      this.$emit('info',this.Lists[0].children[index].id)
    }
  }
}
</script>
<style lang="scss" scoped>
.nav_div {
  width: 173px;
  height: 530px;
  background: #ffffff;
  text-align: center;
  border-radius: 10px;
  border: 2px #d7f0ff solid;

  .ul1 {
    .li1 {
      cursor: pointer;
      font-size: 16px;
      color: #333333;
      line-height: 66px;
      position: relative;
      font-weight: bold;
    }

    .li1:hover {
      background: #d7f0ff;
    }
  }

  // 2级导航
  .ul2_div {
    position: absolute;
    width: 130px;
    right: -130px;
    top: 33px;
    height: 0px;
    overflow: hidden;
    height: 0;

    .ul2 {
      border: 2px #d7f0ff solid;
      width: 120px;
      margin-left: 10px;
      border-radius: 5px;
      background: #fff;
      li{
         width: 120px;
         white-space:nowrap;
         text-overflow: ellipsis;
         overflow: hidden;
         text-align: center;
         padding:0 5px;
      }
      li:hover {
        background: #d7f0ff !important;

      }
    }
  }

  .addclass {
    height: 270px;
    transition: height 0.6s;
  }
}

</style>
